import { asSitemapUrl, defineSitemapEventHandler } from '#imports'
import {$fetch} from "ofetch";

const baseUrl=useRuntimeConfig().public.apiBase
const req=async (url:string,params:any)=>{
    return await $fetch(`${baseUrl}${url}`,{
        method:'get',
        params,
    })
}
export default defineSitemapEventHandler(async () => {
    const arr:any=[];
   const result= await Promise.all([10,20,30].map(type=>req(`/notice/getList`,{
       limit:1000,
       page:1,
       type,
       is_up:1,
   })  ))
    result.map((item)=>{
       const {data,code}=item;
        if(code==200){
            data.list.forEach((i:any)=>{
                arr.push(asSitemapUrl({
                    loc: `/noticeDetail/${i.id}.html`,
                    priority: 0.8,
                }))
            })
        }
    })
    const {data,code}=await req(`/west/getAllDomainList`, {
        page:1,// 页码
        limit:1000,// 每页显示数量
    })
    if(code==200){
        data.list.forEach((i:any)=>{
            arr.push(asSitemapUrl({
                loc: `/whoisDetail/${i.domain}.html`,
                priority: 0.8,
            }))
        })
    }
    return arr;
})